$(document).ready(function() {
	$('#example').dataTable( {
		"bDestroy": true,
		"bProcessing": true,
		"bServerSide": true,
		"sAjaxSource": "ajax_consultaPaciente.php",
		"sScrollY": 200,
		"bJQueryUI": true,
		"bLengthChange": false,
		"bPaginate": false,
		"oLanguage": {
			"LengthMenu": "_MENU_ records per page",
			"sUrl": "../../js/datatable_language.txt"
		},
		"aoColumnDefs": [
			{ "asSorting": [ "asc" ], "aTargets": [0]},
		
		],
		"aoColumns": [ 
			{ "bVisible":    false },
			null,
			null,
			null,
			null,
			{ "bSearchable": false }
		]
	});
	$( "#dialog-form" ).dialog({
		autoOpen: false,
		height: 400,
		width: 650,
		modal: true,
		buttons: {
			"Novo Laudo": function() {
				var bValid = true;
			},
			Cancel: function() {
				$(this).dialog( "close" );
			}
		}
	});
	$('#marcar-todos').click(function(){
		$('table > tbody > tr > td > :checkbox')
		  .attr('checked', $(this).is(':checked'))
		  .trigger('change');
	});
});

function btn_acao(pagina,id) {
	var theForm, id;
	// Start by creating a <form>
	theForm = document.createElement('form');
	theForm.action = pagina;
	theForm.method = 'POST';
	// Next create the <input>s in the form and give them names and values
	input = document.createElement('input');
	input.type = 'hidden';
	input.name = 'id';
	input.value = id;
	
	// Now put everything together...
	theForm.appendChild(input);
	
	// ...and it to the DOM...
	document.getElementById('hidden_form_container').appendChild(theForm);
	// ...and submit it
	theForm.submit();
}


function btn_adicionarPaciente() {
		$("#dialog-form" ).dialog("open");
}
function btn_editarPaciente(pagina,id) {
	var theForm, id;
	// Start by creating a <form>
	theForm = document.createElement('form');
	theForm.action = pagina;
	theForm.method = 'POST';
	// Next create the <input>s in the form and give them names and values
	input = document.createElement('input');
	input.type = 'hidden';
	input.name = 'id';
	input.value = id;
	
	// Now put everything together...
	theForm.appendChild(input);
	
	// ...and it to the DOM...
	document.getElementById('hidden_form_container').appendChild(theForm);
	// ...and submit it
	theForm.submit();
		
		
}

function btn_historicoPaciente() {
		window.location.href = "historico_paciente.php";
}
function btn_iniciarLaudoPaciente() {
		window.location.href = "../laudos/formCad_laudo.php";
}

function btn_agendamentoPaciente() {
		window.location.href = "../laudos/formCad_agendamento.php";
}